export default class extends think.BaseController {
    /**
     * 查询行政区域
     */
    async getAreaAction() {
        const param = this.post();
        try {
            const areaData = await this.service('cms/DeviceService').getAreaData(param.orgId);
            return this.successJson(areaData);
        } catch (error) {
            return this.errorJson(error);
        }
    }
    /**
     * 分页获取设备列表
     */
    async getDeviceAction() {
        const data = this.post();
        try {
            const deviceData = await this.service('cms/DeviceService').getDevice(data);
            return this.successJson(deviceData);
        } catch (error) {
            return this.errorJson(error);
        }
    }

    /**
     * 获取全部设备列表
     */
    async getAllDeviceAction() {
        const data = this.post();
        try {
            const deviceData = await this.service('cms/DeviceService').getAllDevice();
            return this.successJson(deviceData);
        } catch (error) {
            return this.errorJson(error);
        }
    }
    /**
     * 更改设备状态
     */
    async changeDeviceEnableAction() {
        const data = this.post();
        try {
            const isEnable = await this.service('cms/DeviceService').changeDeviceEnable(data);
            return this.successJson(isEnable);
        } catch (error) {
            return this.errorJson(error);
        }
    }

    /**
     * 修改设备信息
     */
    async changeDeviceInfoAction() {
        const data = this.post();
        try {
            const deviceInfo = await this.service('cms/DeviceService').changeDeviceInfo(data);
            return this.successJson(deviceInfo);
        } catch (error) {
            return this.errorJson(error);
        }
    }
    /**
     * 修改设备信息
     */
    async deleteDeviceAction() {
        const data = this.post();
        try {
            const deleteDevice = await this.service('cms/DeviceService').deleteDevice(data);
            return this.successJson(deleteDevice);
        } catch (error) {
            return this.errorJson(error);
        }
    }
}
